package com.itgaohe.controller;


import com.itgaohe.dao.entity.BlogComments;
import com.itgaohe.dto.resp.SearchBlogCommentDTO;
import com.itgaohe.service.BlogCommentsService;
import com.itgaohe.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("blog-comment")
@Tag(name = "博客评论管理", description = "用户相关操作")
public class BlogCommentsController {

    @Autowired
    private BlogCommentsService blogCommentsService;

    //查询博客评论
    @Operation(summary = "根据博客id查询博客评论")
    @GetMapping("/{blogId}")
    public Result getBlogComment(@PathVariable long blogId) {
        List<SearchBlogCommentDTO> commentsByBlogId = blogCommentsService.getCommentsByBlogId(blogId);
        return Result.ok(commentsByBlogId);
    }
    @Operation(summary = "创建博客评论")
    @PostMapping
    public Result addBlogComment(@RequestBody BlogComments blogComments) {
        boolean b = blogCommentsService.addBlogComment(blogComments);
        return Result.ok(b);
    }

}
